package com.atguigu.gulimall.cart.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

@Configuration
public class MyThreadConfig {

    @Bean
    public ThreadPoolExecutor threadPoolExecutor(TreadPoolConfigProperties thread){
        return new ThreadPoolExecutor(thread.getCoreSize(), //核心线程数
                                         thread.getMaxSize(), //最大线程数
                                       thread.getKeepAliveTime(),//时间
                                       TimeUnit.SECONDS,new LinkedBlockingDeque<>(100000),//对列
                                      Executors.defaultThreadFactory(),//线程工厂
                                    new ThreadPoolExecutor.AbortPolicy());//拒绝策略
    }
}
